<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Uc
 *
 * @author sunday 2014.05.26 add
 */
require_once 'BaseChannel.php';

//联赢汇 平台服务器端接入
class Lianyinghui implements BaseChannel {

    //put your code here
    function __construct() {
        
    }

    function android($data) {
        $appid = 1007;
        $appkey = "YekigRvPItzjOS8fkVY8ag==";
        echo $this->payCallBackMethod($cpId, $appkey, ANDROID);
    }

    function ios($data) {
        
    }

    public function payCallBackMethod($cpId, $appkey, $platform) {

        $orderLog = new ChargeOrder();
        $orderLog->log("lianyinghui", $_REQUEST);

        try {
            $responseData = json_decode($request, true);
            $apporder = $_REQUEST['apporder'];	//我方订单号
            $payorder = $_REQUEST['payorder'];	//第三方订单号
            $paymoney = $_REQUEST['paymoney'];
            $sign = $_REQUEST['sign'];
            //print_r($responseData);

            $sign_check = md5($apporder . $paymoney . $appkey);

            if ($sign == $sign_check) {

                $status = STATUS_SUCCESS;

                if (false == $orderLog->recordOrder($status, $paymoney, $apporder, "lianyinghui", $platform,$payorder)) {
                    $orderLog->log("lianyinghui", "order update failed , orderid:" . $apporder . " platform:" . $platform);
                    return 'FAILURE';
                }
                return 'ok'; //返回给sdk server的响应内容 
            } else {
                $orderLog->log("lianyinghui", "checked failed, order:" . $apporder);
                return 'FAILURE'; //返回给sdk server的响应内容 ,对于重复多次通知失败的订单,请参考文档中通知机制。
            }
        } catch (Exception $e) {
            $orderLog->log("lianyinghui", $e->getMessage());
            
            throw new exception($e->getMessage());
        }
        return 'FAILURE'; //返回给sdk server的响应内容 ,对于重复多次通知失败的订单,请参考文档中通知机制。
    }

}

?>